#include <iostream>
#include "test1.pb.h"
using namespace std;

int main()
{
	Person person;
	person.set_id(100);
	person.set_name("zyb",3);
	person.set_email("yuanbo880828@163.com");
	cout << "person.BypeSize():" << person.ByteSize() << endl;;
	cout << "person.TypeName():" << person.GetTypeName() << endl;

	int nBodyLen = person.ByteSize();

	char buff[1024];
	memset(buff, 0, sizeof(buff));
	bool bPackSucceed = person.SerializeToArray(&buff, 1024);

	if (bPackSucceed)
	{
	}
	Person anotherperson;
	bool bUnPackSucceed = anotherperson.ParseFromArray(&buff, nBodyLen);

	cout << "anotherperson:ByteSize" << anotherperson.ByteSize() << endl;
	if (anotherperson.has_name())
	{
		cout << "anotherperson:name:" << anotherperson.name() << endl;
	}
	if (anotherperson.has_email())
	{
		cout << "anotherperson:email:" << anotherperson.email() << endl;
	}

	if (anotherperson.has_id())
	{
		cout << "anotherperson:id:" << anotherperson.id() << endl;
	}

	int bytesize = anotherperson.ByteSize();
	//int b = 100;

	return 0;
}